<template>
  <h3>猜数字</h3>
  <div>
    <div>
      <input type="text" placeholder="请输入数字" v-model="num">
      <button @click="guess">猜</button>
    </div>
  </div>
  <h4>{{info}}</h4>
</template>
<script setup>
import {ref} from "vue";
let num=ref('');
let info=ref('');
let x = parseInt(Math.random()*100)+1;
console.log(`x=${x}`);
function guess(){
   if(num.value<x){
      console.log(info.value);
      info.value="猜小了";
   }else if(num.value>x){
      info.value="猜大了";
   }else{
      info.value="猜对了";
  }
}
</script>

<style scoped>
</style>